//
//  BaseNavigaionViewController.m
//  ECAppNative
//
//  Created by Rathakrishnan on 18/05/2017.
//  Copyright © 2017 Panosoft. All rights reserved.
//

#import "BaseNavigaionViewController.h"

@interface BaseNavigaionViewController ()

@end

@implementation BaseNavigaionViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    //配置属性
    self.shotViewAnimationType = ShotViewAnimationTypeScale;
    self.scaleViewFloat = 0.9;
    
    
//    self.navigationBar.barStyle = UIBarStyleBlack;
//    // 去掉导航栏底部的线
//    [self.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
//    [self.navigationBar setShadowImage:[UIImage new]];
//    //渐变
//    [self.navigationBar.layer insertSublayer:[self gradientLayer] atIndex:0];
     
     UINavigationBar *navigationBar = [UINavigationBar appearance];
     
     [navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
     navigationBar.tintColor = [UIColor cjMainColor];
     navigationBar.barTintColor = [UIColor cjMainColor];

}

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
    
    if (self.childViewControllers.count > 0) {
        viewController.hidesBottomBarWhenPushed = YES;
        
        UIImage *buttonImage = [[UIImage imageNamed:@"ic_back_btn_normal"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] ;
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        [button setImage:buttonImage forState:UIControlStateNormal];
        button.imageEdgeInsets = UIEdgeInsetsMake(0, -40, 0, 0);
        button.frame = CGRectMake(0, 0, buttonImage.size.width+20, buttonImage.size.height+10);
       // button.tintColor = self.navigationController.navigationBar.tintColor;
        button.tintColor = [UIColor cjMainColor];
        [button addTarget:self action:@selector(popToPre) forControlEvents:UIControlEventTouchUpInside];

        viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
    }
    [super pushViewController:viewController animated:animated];
}

- (void)popToPre{
    
    [self yn_popViewController];
}


+ (UIBarButtonItem*)barButtonItemWithImage:(UIImage*)imageN ImageH:(UIImage*)imageH target:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents
{
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setImage:imageN forState:UIControlStateNormal];
    [btn sizeToFit];
    [btn addTarget:target action:action forControlEvents:controlEvents];
    return [[UIBarButtonItem alloc]initWithCustomView:btn];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

//- (CAGradientLayer *)gradientLayer {
//    CAGradientLayer *gradientLayer = [[CAGradientLayer alloc]init];
//    // CGColor是无法放入数组中的，必须要转型。223  48 49 
//    gradientLayer.colors = @[
//                             (__bridge id)[UIColor colorWithRed:78 / 255.0 green:143 / 255.0 blue:1.0 alpha:1.0].CGColor,
//                             (__bridge id)[UIColor colorWithRed:39 / 255.0 green:196 / 255.0 blue:254 / 255.0 alpha:1.0].CGColor,
//                             (__bridge id)[UIColor colorWithRed:60 / 255.0 green:143 / 255.0 blue:1.0 alpha:1.0].CGColor,
//                             ];
//    // 颜色分割线
//    gradientLayer.locations = @[@0, @0.8,@1.5];
//    // 颜色渐变的起点和终点，范围为 (0~1.0, 0~1.0)
//    gradientLayer.startPoint = CGPointMake(0, 0);
//    gradientLayer.endPoint = CGPointMake(1.0, 0);
//    gradientLayer.frame = CGRectMake(0, -20, self.navigationBar.bounds.size.width, 20 + self.navigationBar.bounds.size.height);
//    return gradientLayer;
//}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
